package com.atguigu.iterator;

import java.util.Iterator;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:
 * @create: 2022-03-07 09:31
 **/
public class ComputerCollege implements College {

    //与ComputerCollegeIterator迭代器保持一致（集合方式一致，数组）
    Department[] departments;
    //保存当前数组的对象个数
    int numOfDepartment = 0;

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("java", "java专业");
        addDepartment("php", "php专业");
        addDepartment("大数据", "大数据专业");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        departments[numOfDepartment] = new Department(name, desc);
        numOfDepartment += 1;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
